### 4.1 `clearerr`, `clearerr_unlocked`—clear file or stream error indicator

Synopsis

         #include <stdio.h>
         void clearerr(FILE *fp);

         #define _BSD_SOURCE
         #include <stdio.h>
         void clearerr_unlocked(FILE *fp);

Description
The `stdio` functions maintain an error indicator with each file pointer fp, to record whether any read or write errors have occurred on the associated file or stream. Similarly, it maintains an end-of-file indicator to record whether there is no more data in the file.

Use `clearerr` to reset both of these indicators.

See `ferror` and `feof` to query the two indicators.

`clearerr_unlocked` is a non-thread-safe version of `clearerr`. `clearerr_unlocked` may only safely be used within a scope protected by flockfile() (or ftrylockfile()) and funlockfile(). This function may safely be used in a multi-threaded program if and only if they are called while the invoking thread owns the (FILE *) object, as is the case after a successful call to the flockfile() or ftrylockfile() functions. If threads are disabled, then `clearerr_unlocked` is equivalent to `clearerr`.

Returns
`clearerr` does not return a result.

Portability
ANSI C requires `clearerr`.

`clearerr_unlocked` is a BSD extension also provided by GNU libc.

No supporting OS subroutines are required.